Production: Create Production Stack

We'll cover the following

Objective#

  • Create separate environments for production.

Steps#

  • Create a separate prod stack for production.

Adding the prod stage#

Extracting the staging stack out of the main template was most of the work, so adding prod is going to be quite straightforward.

First, let’s add a deployment group so that our production hosts can be configured for deployment.

main.yml

Line #8: We could have chosen to put the deployment groups in stage.yml, but it is often useful to have different deployment configurations for different stages. For example, here we set the prod deployment to go on one host at a time, whereas the staging deployment was set to go all at once.

Next, we’ll add a new stage in our Pipeline resource called Prod at the end of the list.

main.yml

Then we’ll add the new nested stack to main.yml.

main.yml

Line #3: Updates to the prod stack will not be enacted until the staging stack successfully applies stack updates.

Finally, we need to add an output in main.yml to return the prod endpoint.

And now let’s deploy.

terminal

The staging endpoint should still be working when the deployment finishes, but our new production endpoint won’t be yet. This is because the deployment groups are configured so that the ASG will launch all new instances with the most recent revision deployed. But there will be no recent revision until the first proper deployment occurs. To fix this, we need to go to our pipeline and click Release Changes in order to get a deployment to prod. Once deployment finishes, then the prod hosts should start responding as well.

terminal

Let’s wrap this up by pushing these changes to our GitHub repository.

terminal
Please provide values for the following:
username
Not Specified...
AWS_ACCESS_KEY_ID
Not Specified...
AWS_SECRET_ACCESS_KEY
Not Specified...
AWS_REGION
us-east-1
Github_Token
Not Specified...
/
package.json
stage.yml
server.js
main.yml
github.sh
setup.yml
deploy-infra.sh
stop-service.sh
start-service.sh
buildspec.yml
appspec.yml

In order to get a pictorial view of our developed cloudformation stack so far, below is the design view which shows the resources we created and their relationships.

Staging & Production stack
Staging & Production stack

In the next lesson, we will access our application from a custom domain.

Production: Create Staging Stack
Custom Domains: Register Domain with Route 53
Mark as Completed
Report an Issue